import {inject, Injectable} from "@angular/core";
import {MatDialog} from "@angular/material/dialog";
import {SelfDialogComponent} from "../../components/selfDialog/selfDialog.component";

@Injectable()
export class SelfDialogWrap {
  readonly dialog = inject(MatDialog);
  openDialog(msg: string, type: 'dialog' | 'toast' = 'dialog', success?: () => void, fail?: () => void): void {
    let data = {
      title: '提示',
      content: msg,
      showCancel: type !== 'toast',
      confirm: '确定',
      cancel: '取消',
      success: success,
      fail: fail
    }
    this.dialog.open(SelfDialogComponent, {
      width: '250px',
      enterAnimationDuration: 1,
      exitAnimationDuration: 1,
      data: data
    });
  }
}
